home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / library / help / tcl / control / loop < prev    next >
Encoding:
Text File  |  1993-10-26  |  1.9 KB  |  36 lines  |  [TEXT/$Tcl]

  1.  
  2.  
  3.           loop var first limit ?increment? body
  4.                Loop is a looping command, similar in behavior  to  the
  5.                Tcl  for  statement,  except  that  the  loop statement
  6.                achieves substantially higher performance and is easier
  7.                to  code when the beginning and ending values of a loop
  8.                are known, and the loop variable is to  be  incremented
  9.                by a known, fixed amount every time through the loop.
  10.  
  11.                 The var argument is the name of a  Tcl  variable  that
  12.                will  contain the loop index.  The loop index is set to
  13.                the value specified by first.  The Tcl  interpreter  is
  14.                invoked  upon  body  zero  or  more times, where var is
  15.                incremented by increment every time through  the  loop,
  16.                or by one if increment is not specified.  Increment can
  17.                be negative in which case the  loop  will  count  down-
  18.                wards.
  19.  
  20.                When var reaches limit, the loop terminates  without  a
  21.                subsequent  execution  of  body.   For instance, if the
  22.                original loop parameters would cause loop to terminate,
  23.                say first was one, limit was zero and increment was not
  24.                specified or was non-negative, body is not executed  at
  25.                all and loop returns.
  26.  
  27.                The first, limit and increment are integer expressions.
  28.                They  are  only  evaulated once at the beginning of the
  29.                loop.
  30.  
  31.                If a continue command is invoked within body  then  any
  32.                remaining commands in the current execution of body are
  33.                skipped, as in the for command.  If a break command  is
  34.                invoked  within  body then the loop command will return
  35.                immediately.  Loop returns an empty string.
  36.